package com.heima.statics.controller;

import com.heima.model.aritlce.dto.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.statics.service.ArticleStaticService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping(path = "/article/static")
public class ArticleStaticController {

    @Resource
    private ArticleStaticService articleStaticService;

    /**
     * 生成文章静态详情页面
     *
     * @param id
     * @param dto
     * @return
     */
    @PostMapping(path = "/{id}")
    public ResponseResult<String> generateHtml(@PathVariable("id") Long id, @RequestBody ArticleDto dto) {
        String url = articleStaticService.buildArticleHtml(id, dto);
        dto.setStaticUrl(url);
        return ResponseResult.success(url);
    }
}